import { getRowNumber } from 'src/boot/grid';
export const createGridOptions = () => ({
  getRowStyle: (params: any) => {
    if (params.data.isNeedConfirm == true && params.data.confirmUser == null) {
      return {
        background: 'rgba(114,114,114,25%)',
      };
    } else {
      return {
        background: '#000',
      };
    }
  },
});

export const createColumnDefs = () => [
  {
    headerName: '序号',
    field: 'ROW_NUMBER',
    width: 100,
    checkboxSelection: true,
    headerCheckboxSelection: true,
    headerCheckboxSelectionFilteredOnly: true,
    valueGetter: getRowNumber,
  },

  {
    headerName: '报警时间',
    field: 'createTime',
    width: 160,
    sort: 'desc',
  },
  {
    headerName: '报警内容',
    field: 'content',
    width: 220,
  },

  {
    headerName: '级别',
    field: 'level',
    width: 90,
  },
  {
    headerName: '代码',
    field: 'code',
    width: 90,
  },
  {
    headerName: '操作建议',
    field: 'handlingSuggestions',
    width: 120,
  },
  {
    headerName: '报警确认',
    cellRenderer: 'ConfirmButton',
    field: 'isNeedConfirm',
    width: 120,
    valueFormatter: (params: any) => {
      if (params.data.isNeedConfirm === true) {
        return '确认';
      } else if (params.data.confirmUser) {
        return '已确认';
      } else {
        return '已确认';
      }
    },
  },
];
